Opc.Ua.Core
Implicit Type Conversion(NodeId,Byte[]) Operator
Example 



Opc.Ua Namespace > NodeId Class > Implicit Type Conversion Operator : Implicit Type Conversion(NodeId,Byte[]) Operator
The System.Byte[] array to compare this node to
Converts a byte array to an opaque node identifier.
Syntax
'Declaration
 
Overloads Public Operator Widening CType( _
   ByVal value() As Byte _
) As NodeId
'Usage
 
public NodeId operator implicit( 
   byte[] value
)
public:
operator NodeId^ ( 
   array<byte>^ value
)

Parameters

value
The System.Byte[] array to compare this node to
Remarks
This operator allows you to compare a NodeId to an array of Bytes.
Example

This produces the following output (taken from C# example):

Comparing NodeId to Byte[] Comparing ABCDE to ABCDE = [equals] True Comparing ABCDE to ABCDE = [ == ] True Comparing ABCDE to abcde = [equals] False Comparing ABCDE to abcde = [ == ] False

//define our 2 Byte[] ids, and then define our node to use the first id.
byte[] id1 = new byte[] { 65, 66, 67, 68, 69 };
byte[] id2 = new byte[] { 97, 98, 99, 100, 101 };
NodeId node1 = new NodeId(id1);
            
//convert our bytes to string so we can display them 
string id1String = System.Text.ASCIIEncoding.ASCII.GetString(id1);
string id2String = System.Text.ASCIIEncoding.ASCII.GetString(id2);
            
//now to compare the node to the guids
Utils.LogInfo("\n\nComparing NodeId to Byte[]");
Utils.LogInfo("\tComparing {0} to {0} = [equals] {2}", id1String, id1String, node1.Equals(id1));
Utils.LogInfo("\tComparing {0} to {0} = [  =   ] {2}", id1String, id1String, node1 == id1);
Utils.LogInfo("\tComparing {0} to {1} = [equals] {2}", id1String, id2String, node1.Equals(id2));
Utils.LogInfo("\tComparing {0} to {1} = [  =   ] {2}", id1String, id2String, node1 == id2);
'define our 2 Byte[] ids, and then define our node to use the first id.
Dim id1 As Byte() = New Byte() { 65, 66, 67, 68, 69 }
Dim id2 As Byte() = New Byte() { 97, 98, 99, 100, 101 }
Dim node1 As NodeId = New NodeId(id1)
            
'convert our bytes to string so we can display them 
Dim id1String As String = System.Text.ASCIIEncoding.ASCII.GetString(id1)
Dim id2String As String = System.Text.ASCIIEncoding.ASCII.GetString(id2)
            
'now to compare the node to the guids
Utils.LogInfo("Comparing NodeId to Byte()")
Utils.LogInfo("Comparing {0} to {0} = [equals] {2}", id1String, id1String, node1.Equals(id1))
Utils.LogInfo("Comparing {0} to {0} = [  =   ] {2}", id1String, id1String, node1 = id1)
Utils.LogInfo("Comparing {0} to {1} = [equals] {2}", id1String, id2String, node1.Equals(id2))
Utils.LogInfo("Comparing {0} to {1} = [  =   ] {2}", id1String, id2String, node1 = id2)
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

NodeId Class
NodeId Members
Overload List